#include <gtest/gtest.h>

// TODO: fix up include/source directories so we
// don't end up using relative paths like this
#include "../lexer.h"

using std::string;

TEST(LexerTest, SymbolExtractionTest)
{
	std::string input("12345 identifier 0xff");

	Lexer lexer(input);

	// We expect an integer followed by an identifier followed by another integer
	EXPECT_EQ(intliteral, lexer.Lex());
	EXPECT_EQ(identifier, lexer.Lex());
	EXPECT_EQ(intliteral, lexer.Lex());
}


TEST(LexerTest, ValueExtractionTest)
{
	// we should probably use a text fixture for this stuff
	std::string input("12345 identifier 0xff");
	Lexer lexer(input);

	lexer.Lex();
	Token token = lexer.GetCurrentToken();

	EXPECT_EQ(12345, token.ival);
}

//
// Test the extraction of operator symbols
//
TEST(LexerTest, OperatorSymbols)
{
	string input("= . : ,");
	Lexer lexer(input);

	Token t;

	EXPECT_EQ(equals, lexer.Lex());
	t = lexer.GetCurrentToken();
	EXPECT_EQ("operator", t.type);
	EXPECT_EQ("=", t.value);

	EXPECT_EQ(period, lexer.Lex());
	t = lexer.GetCurrentToken();
	EXPECT_EQ("operator", t.type);
	EXPECT_EQ(".", t.value);

	EXPECT_EQ(colon, lexer.Lex());
	t = lexer.GetCurrentToken();
	EXPECT_EQ("operator", t.type);
	EXPECT_EQ(":", t.value);

	EXPECT_EQ(comma, lexer.Lex());
	t = lexer.GetCurrentToken();
	EXPECT_EQ("operator", t.type);
	EXPECT_EQ(",", t.value);

}